﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;

namespace Habito.Reference
{
	public partial class Index : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!string.IsNullOrEmpty(Request.QueryString["id"]))
			{
				ViewState["id"] = Request.QueryString["id"];
			} 
		}

		protected override void OnInit(System.EventArgs e)
		{
			if (Request.QueryString["GetAllReference"] == "1")
			{
				Ajax.BLL.References bll = new Ajax.BLL.References();
				List<Ajax.Model.References> sa = bll.GetModelList("");
				string s = JsonConvert.SerializeObject(sa);
				Response.Write(s);
				Response.End();
			}
			else if (Request.QueryString["Getcontent"] == "1")
			{
				int id = int.Parse(Request.QueryString["id"]);
				Ajax.BLL.References bll = new Ajax.BLL.References();
				Ajax.Model.References sa = bll.GetModel(id);
				string s = JsonConvert.SerializeObject(sa);
				Response.Write(s);
				Response.End();
			}
		}
	}
}